import dao.Accountdao;
import dao.Roledao;
import dao.Userdao;
import domain.Account;
import domain.Accountuser;
import domain.Role;
import domain.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import tool.*;
import org.apache.log4j.Logger;
public class test {
    public static void main(String[] args) throws Exception{
        InputStream in=Resources.getResourceAsStream("mybatis.xml");
        SqlSessionFactoryBuilder builder=
                new SqlSessionFactoryBuilder();
        SqlSessionFactory factory=builder.build(in);
        SqlSession sqlSession=factory.openSession();
        Userdao userdao=sqlSession.getMapper(Userdao.class);
        List<User>list=userdao.findall();
        for (User u :list
                ) {
            System.out.print(u);
            System.out.println(u.getRoles());
        }
        sqlSession.close();
    }
    @Test
    public void findainid(){
        Accountdao accountdao=
                SqlSessionUtil.getSqlSession().getMapper(Accountdao.class);
        List<Account>list=accountdao.findall();
        for (Account a:list
             ) {
            System.out.println(a);
            System.out.println(a.getUsers());
        }
    }
    @Test
    public void findbyid(){
        Userdao userdao=
                SqlSessionUtil.getSqlSession().getMapper(Userdao.class);
        User user=userdao.findbyid(41);
        System.out.println(user);
    }

}
